import {getCodeAPI, registerAPI} from "@/api/registerApi";

const actions = {
    /* 获取验证码的actions */
    async fetchCode(context, phone) {
        const result = await getCodeAPI(phone)
        if (result.code !== 200) return Promise.reject("获取验证码失败")
        return Promise.resolve(result.data)
    },
    /* 注册用户的actions */
    async registerUser(context, data) {
        const result = await registerAPI(data)
        if (result.code!==200) return Promise.reject(result.message)
        return Promise.resolve(result.message)
    }
}
const mutations = {}
const state = () => {
    return {}
}
const getters = {}
export default {
    actions,
    mutations,
    state,
    getters,
    namespaced: true
}
